package com.ruoyi.fly.controller;

import com.ruoyi.common.core.controller.BaseController;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.fly.domain.PcSetting;
import com.ruoyi.fly.domain.vo.SettingVo;
import com.ruoyi.fly.service.PcSettingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Validated
@RestController
@RequestMapping("/pcSetting")
@AllArgsConstructor
@Api(tags = "设置管理")
public class PcSettingController extends BaseController {
    @Autowired
    private PcSettingService pcSettingService;

    /**
     * 查询设置管理列表
     */
    @ApiOperation(value = "查询设置管理列表")
    @PostMapping("/list")
    public TableDataInfo list(PcSetting pcSetting) {
        startPage();
        List<PcSetting> list = pcSettingService.selectPcSettingList(pcSetting);
        return getDataTable(list);
    }

    /**
     * 获取设置管理详细信息
     */
    @ApiOperation(value = "获取设置管理详细信息")
    @GetMapping(value = "/selete/{settingId}")
    public R getInfo(@PathVariable("settingId") String settingId) {
        return R.ok(pcSettingService.selectPcSettingBySettingId(settingId));
    }

    /**
     * 新增设置管理
     */
    @ApiOperation(value = "新增设置管理")
    @PostMapping("/add")
    public R add(@RequestBody SettingVo settingVo) {
        return pcSettingService.insertPcSetting(settingVo);
    }

    /**
     * 修改设置管理
     */
    @ApiOperation(value = "修改设置管理")
    @PostMapping("/edit")
    public R edit(@RequestBody SettingVo settingVo) {
        return pcSettingService.updatePcSetting(settingVo);
    }

    /**
     * 删除设置管理
     */
    @ApiOperation(value = "删除设置管理")
    @PostMapping("/delete/{settingIds}")
    public R remove(@PathVariable String[] settingIds) {
        return pcSettingService.deletePcSettingBySettingIds(settingIds);
    }
}